package company.permissionsystem.service;

import company.permissionsystem.dao.AdminDao;
import company.permissionsystem.model.entity.SysPermission;
import company.permissionsystem.model.entity.SysRole;
import company.permissionsystem.model.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminService {

    @Autowired
    private AdminDao adminDao;


    public List<SysUser> findAllAdmin() {
        return adminDao.findAllAdmin();
    }

    public List<SysRole> findAllRole() {
        List<SysRole> lists = adminDao.findAllRole();
        return lists;
    }

    public List<SysPermission> findAllSysPermission() {
        List<SysPermission> list = adminDao.findAllPermission();
        for (SysPermission s : list) {
            s.setSysRoles(adminDao.setSysRoleNameByPermission(s.getId()));
        }
        return list;
    }
}
